/*
 * @Descripttion: trait继承
 * @Author: yubo
 * @Date: 2022-11-02 15:42:10
 * @LastEditTime: 2022-11-02 15:57:32
 */
trait Page {
    fn set_page(&self, p: i32) {
        println!("Page Default: {}", p);
    }
}

trait PerPage {
    fn set_perpage(&self, num: i32) {
        println!("Per Page Default: {}", num);
    }
}

struct MyPaginate {
    page: i32
}

impl Page for MyPaginate{}

impl PerPage for MyPaginate{}

//Page + PerPage 表示Paginate 同时继承了 Page和PerPage 两个trait
trait Paginate: Page + PerPage {
    fn set_skip_page(&self, num: i32) {
        println!("Skip Page: {:?}", num);
    }
}

//为所有拥有 Page和PerPage行为的类型，实现Paginate
impl <T: Page + PerPage> Paginate for T{}

fn main() {
    let my_paginate = MyPaginate{page: 1};
    my_paginate.set_page(2);
    my_paginate.set_perpage(100);
    my_paginate.set_skip_page(102);
}